home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / CUGUK / PROG_TOO / C027B.ZIP / TOP / INST.H < prev    next >
Text File  |  1990-03-30  |  3KB  |  100 lines

  1. /* Copyright (c) 1988 by Sozobon, Limited.  Author: Tony Andrews
  2.  *
  3.  * Permission is granted to anyone to use this software for any purpose
  4.  * on any computer system, and to redistribute it freely, with the
  5.  * following restrictions:
  6.  * 1) No charge may be made other than reasonable charges for reproduction.
  7.  * 2) Modified versions must be clearly marked as such.
  8.  * 3) The authors are not responsible for any harmful consequences
  9.  *    of using this software, even if they result from defects in it.
  10.  */
  11.  
  12. /*
  13.  * Misc. define's, etc. for instruction parsing.
  14.  */
  15.  
  16. struct    opnd {
  17.     unsigned char    amode;    /* addressing mode used */
  18.     unsigned char    areg;    /* primary register */
  19.     unsigned char    ireg;    /* index register, if applicable */
  20.     long    disp;        /* also used for immediate data */
  21.     char    *astr;        /* pointer to any symbol present */
  22. };
  23.  
  24. /*
  25.  * Addressing modes (in 'amode')
  26.  */
  27. #define    NONE    0        /* operand unused */
  28. #define    REG    1        /* register direct */
  29. #define    IMM    2        /* immediate */
  30. #define    ABS    3        /* absolute */
  31. #define    REGI    4        /* reg. indirect */
  32. #define    REGID    5        /* reg. indirect, w/ displacement */
  33. #define    REGIDX    6        /* reg. indirect, w/ displacement & index */
  34. #define    PCD    7        /* PC relative, w/ displacement */
  35. #define    PCDX    8        /* PC relative, w/ displacement & index */
  36.  
  37. #define    XLONG    0x10        /* long index register used */
  38. #define    SYMB    0x20        /* symbol used, not constant */
  39. #define    INC    0x40        /* auto-increment */
  40. #define    DEC    0x80        /* auto-decrement */
  41.  
  42. #define    MMASK    0x0f        /* mode mask */
  43. #define    FMASK    0xf0        /* flag mask */
  44.  
  45. #define    M(x)    ((x) & MMASK)
  46. #define    F(x)    ((x) & FMASK)
  47.  
  48. /*
  49.  * Registers
  50.  */
  51.  
  52. #define    FIRSTREG    0
  53. #define    A0    0
  54. #define    A1    1
  55. #define    A2    2
  56. #define    A3    3
  57. #define    A4    4
  58. #define    A5    5
  59. #define    A6    6
  60. #define    A7    7
  61. #define    SP    7    /* alias for A7 */
  62. #define    D0    8
  63. #define    D1    9
  64. #define    D2    10
  65. #define    D3    11
  66. #define    D4    12
  67. #define    D5    13
  68. #define    D6    14
  69. #define    D7    15
  70. #define    LASTREG    15
  71.  
  72. #define    ISD(x)    ((x) >= D0 && (x) <= D7)    /* is 'x' a  D reg. */
  73. #define    ISA(x)    ((x) >= A0 && (x) <= A7)    /* is 'x' an A reg. */
  74. #define    RM(x)    (1 << (x))            /* form a register mask */
  75.  
  76. /*
  77.  * DOK(x) - evaluates TRUE if 'x' is okay for a displacement value.
  78.  *
  79.  * 'x' must be of type "long"
  80.  */
  81. #define    DOK(x)    ((((int) ((x)>>16)) == 0xffff) || (((int) ((x) >> 16)) == 0))
  82.  
  83. struct    inst {
  84.     char    opcode;            /* type of instruction */
  85.     struct    opnd    src, dst;    /* optional operands */
  86.     char    flags;            /* length, etc. */
  87.     int    rref, rset;
  88.     int    live;            /* regs. live after this inst. */
  89.     struct    inst    *next;
  90.     struct    inst    *prev;
  91. };
  92.  
  93. /*
  94.  * Instruction flags
  95.  */
  96.  
  97. #define    LENB    0x01
  98. #define    LENW    0x02
  99. #define    LENL    0x04
  100.